package top.anydata.lifeofcode.lifesystem.dao.sys.user;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import top.anydata.lifeofcode.lifesystem.entity.sys.user.SysAuthRoleEntity;
import top.anydata.lifeofcode.lifesystem.entity.sys.user.SysAuthUserRoleEntity;

import java.util.List;

@Repository
public interface ISysAuthUserRoleRepository extends JpaRepository<SysAuthUserRoleEntity,Integer>{
    void deleteByUserIdAndRoleId(int userId, int roleId);
    List<SysAuthUserRoleEntity> findRolesByUserId(int userId);

    @Override
    @Modifying
    @Query("update SysAuthUserRoleEntity set isDeleted = 1 where id = ?1")
    void deleteById(Integer integer);

    List<SysAuthUserRoleEntity> findByRoleIdAndUserId(int roleId, int userId);
}
